src/ostree/ot-admin-builtin-pull-deploy.c \
src/ostree/ot-admin-builtin-os-init.c \
src/ostree/ot-admin-builtin-install.c \
+ src/ostree/ot-admin-builtin-run-triggers.c \
src/ostree/ot-admin-builtin-upgrade.c \
src/ostree/ot-admin-builtin-update-kernel.c \
src/ostree/ot-admin-builtins.h \
--- /dev/null
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2012 Colin Walters <walters@verbum.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Colin Walters <walters@verbum.org>
+ */
+
+#include "config.h"
+
+#include "ot-admin-builtins.h"
+#include "ot-admin-functions.h"
+#include "ostree.h"
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <glib/gi18n.h>
+
+static GOptionEntry options[] = {
+ { NULL }
+};
+
+gboolean
+ot_admin_builtin_run_triggers (int argc, char **argv, GFile *ostree_dir, GError **error)
+{
+ GOptionContext *context;
+ gboolean ret = FALSE;
+ ot_lobj GFile *rootdir = NULL;
+ __attribute__((unused)) GCancellable *cancellable = NULL;
+
+ context = g_option_context_new ("[ROOT] - Run triggers (regenerate caches, etc.)");
+ g_option_context_add_main_entries (context, options, NULL);
+
+ if (!g_option_context_parse (context, &argc, &argv, error))
+ goto out;
+
+ if (argc >= 2)
+ {
+ rootdir = g_file_new_for_path (argv[1]);
+ }
+ else
+ {
+ if (!ot_admin_get_sysroot_from_proc_cmdline (&rootdir, cancellable, error))
+ goto out;
+ if (rootdir == NULL)
+ {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "No ostree= kernel argument found");
+ goto out;
+ }
+ }
+
+ if (!ostree_run_triggers_in_root (rootdir, cancellable, error))
+ goto out;
+
+ ret = TRUE;
+ out:
+ if (context)
+ g_option_context_free (context);
+ return ret;
+}
gboolean ot_admin_builtin_prune (int argc, char **argv, GFile *ostree_dir, GError **error);
gboolean ot_admin_builtin_pull_deploy (int argc, char **argv, GFile *ostree_dir, GError **error);
gboolean ot_admin_builtin_diff (int argc, char **argv, GFile *ostree_dir, GError **error);
+gboolean ot_admin_builtin_run_triggers (int argc, char **argv, GFile *ostree_dir, GError **error);
gboolean ot_admin_builtin_update_kernel (int argc, char **argv, GFile *ostree_dir, GError **error);
gboolean ot_admin_builtin_upgrade (int argc, char **argv, GFile *ostree_dir, GError **error);
return query_symlink_target_allow_noent (previous_path, out_deployment,
cancellable, error);
}
+
+gboolean
+ot_admin_get_sysroot_from_proc_cmdline (GFile **out_deploy_target,
+ GCancellable *cancellable,
+ GError **error)
+{
+ gboolean ret = FALSE;
+ gs_unref_object GFile *proc_cmdline = g_file_new_for_path ("/proc/cmdline");
+ gs_unref_object GFile *ret_deploy_target = NULL;
+ gs_free char *contents = NULL;
+ gsize contents_len;
+ char **cmdline_argv = NULL;
+ char **iter;
+
+ if (!g_file_load_contents (proc_cmdline, cancellable, &contents, &contents_len, NULL,
+ error))
+ goto out;
+
+ cmdline_argv = g_strsplit (contents, " ", -1);
+
+ for (iter = cmdline_argv; *iter; iter++)
+ {
+ const char *arg = *iter;
+ if (strncmp (arg, "ostree=", 7) == 0)
+ {
+ gs_free char *subpath = g_strdup (arg + 7);
+ gs_unref_object GFile *deploydir = g_file_new_for_path ("/sysroot/ostree/deploy");
+ ret_deploy_target = g_file_resolve_relative_path (deploydir, subpath);
+ break;
+ }
+ }
+
+ ret = TRUE;
+ ot_transfer_out_value (out_deploy_target, &ret_deploy_target);
+ out:
+ g_strfreev (cmdline_argv);
+ return ret;
+}
GCancellable *cancellable,
GError **error);
+gboolean ot_admin_get_sysroot_from_proc_cmdline (GFile **out_deploy_target,
+ GCancellable *cancellable,
+ GError **error);
+
G_END_DECLS
#endif
{ "prune", ot_admin_builtin_prune },
{ "update-kernel", ot_admin_builtin_update_kernel },
{ "config-diff", ot_admin_builtin_diff },
+ { "run-triggers", ot_admin_builtin_run_triggers },
{ NULL, NULL }
};